package com.bird.设计模式.结构型.装饰者模式.v1;

/**
 * @data 2022/3/14 17:10
 * @author: bird
 * @description: 业务场景: 公司楼下买煎饼.... 加鸡蛋 加香肠....
 * <p>
 * 优点：继承可以扩展业务功能
 * 缺点：类会继承爆炸 原因是因为煎饼有不同的组合
 * 改进方式：通过装饰者模式来动态的给对象添加功能.
 */
public class Test {

    public static void main(String[] args) {

        //煎饼类
        BatteryCake batteryCake = new BatteryCake();
        System.out.println(batteryCake.getDesc() + " 销售价格: " + batteryCake.cost());

        // 煎饼+鸡蛋类
        BatteryCakeWithEgg batteryCakeWithEgg = new BatteryCakeWithEgg();
        System.out.println(batteryCakeWithEgg.getDesc() + " 销售价格: " + batteryCakeWithEgg.cost());

        //煎饼+鸡蛋+香肠类
        BatteryCakeWithEggSausage batteryCakeWithEggSausage = new BatteryCakeWithEggSausage();
        System.out.println(batteryCakeWithEggSausage.getDesc() + " 销售价格: " + batteryCakeWithEggSausage.cost());


    }
}
